package com.qfedu.controller;

import com.qfedu.entity.ListSong;
import com.qfedu.entity.ResponseData;
import com.qfedu.entity.Song;
import com.qfedu.entity.SongList;
import com.qfedu.service.SongListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import javax.websocket.Session;
import java.util.List;

/**
 * 歌单相关业务
 */
@RestController
public class SongListController {

    @Autowired
    private SongListService songListService;

    @RequestMapping("/songList")
    public List<SongList> getSongList(){

        return songListService.findAllSongList();

    }

    /**
     * 根据类型查询歌单
     * @param style
     * @return
     */
    @RequestMapping("/songList/style/detail")
    public List<SongList> getSongListOfStyle(String style) {
        List<SongList> list = songListService.findSongStyleList(style);
        return list;
    }


    @RequestMapping("/listSong/detail")
    public List<ListSong> getListSongOfSongId(int songListId,HttpSession session) {

        return songListService.getListSongOfSongId(songListId);
    }

    @RequestMapping("/song/detail")
    public List<Song> getSongOfId(int id) {
        return songListService.getSongOfId(id);
    }

    @RequestMapping("/song/singer/detail")
    public List<Song> getSongOfSingerId(int singerId){

        return songListService.getSongOfSingerId(singerId);
    }

    @RequestMapping("/song/singerName/detail")
    public List<Song> getSongOfSingerName(String name){

        return songListService.getSongOfSingerName(name);
    }

    @RequestMapping("/songList/likeTitle/detail")
    public List<SongList> getSongListOfLikeTitle(String title){

        return songListService.getSongListOfLikeTitle(title);
    }

    /**
     * 更新歌曲信息
     * @param song
     * @return
     */
    @RequestMapping("/song/update")
    public Boolean updateSongMsg(Song song){

        return songListService.updateSongMsg(song);
    }

    /**
     * 删除歌曲
     * @param id
     * @return
     */
    @RequestMapping("/song/delete")
    public Boolean deleteSong(int id){

        return songListService.deleteSong(id);
    }

    /**
     * 更新歌单信息
     * @param songList
     * @return
     */
    @RequestMapping("/songList/update")
    public ResponseData<String> updateSongListMsg(SongList songList){

        return songListService.updateSongListMsg(songList);
    }

    /**
     * 删除歌单
     * @param id
     * @return
     */
    @RequestMapping("/songList/delete")
    public Boolean deleteSongList(int id){

        return songListService.deleteSongList(id);
    }

    /**
     * 给歌单添加歌曲
     * @param listSong
     * @return
     */
    @RequestMapping("/ListSong/add")
    public ResponseData<String> setListSong(ListSong listSong){

        return songListService.setListSong(listSong);
    }

    /**
     * 删除歌单里的歌曲
     * @param songId
     * @return
     */
    @RequestMapping("/ListSong/delete")
    public Boolean deleteListSong(int songId){

        return songListService.deleteListSong(songId);
    }

    /**
     * 添加歌单
     * @param songList
     * @return
     */
    @RequestMapping("/songList/add")
    public ResponseData<String> setSongList(SongList songList){

        return songListService.setSongList(songList);
    }

    @RequestMapping("/song")
    public List<Song> getAllSong(){

        return songListService.getAllSong();
    }
}
